package com.WJY.dao;

import com.WJY.pojo.Flower;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FlowerDao {
    //查询所有
    @Select("select * from demo.flowers")
    List<Flower> queryFlowerList();

    //id查询
    @Select("select * from demo.flowers where flowerId = #{id}")
    Flower queryFlowerById(@Param("id") int id);

    //名字模糊查询
    @Select("select * from demo.flowers where flowerName like '%${name}%'")
    List<Flower> queryFlowerByName(@Param("name") String name);

    //id删除
    @Delete("delete from demo.flowers where flowerId = #{id}")
    int delFlowerById(@Param("id") int id);

    //增加花朵
    @Insert("insert into demo.flowers ( flowerName, category, price) values (#{flowerName},#{category},#{price})")
    int addFlower(Flower flower);

    //修改花朵
    @Update("update demo.flowers set flowerName = #{flowerName}, category = #{category},price = #{price} where flowerId = #{flowerId}")
    int updateFlower(Flower flower);

}
